<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="js/jquery-1.8.3.js"></script>
</head>
<body>
用户名:<input type="text" name="name" id="name"><br>
密码:<input type="password" name="pass" id="pass"><br>
<input type="button" value="添加" id="add">
<table>
    <thead>
        <td>账号</td>
        <td>密码</td>
    </thead>
    <tbody id="ad">

    </tbody>
</table>
</body>
<script>
    $(function () {

        search();

        $("#add").click(function () {
            $.ajax({
                url:"add",
                type:"POST",
                data:{"name":$("#name").val(),"pass":$("#pass").val()},
                success:function (data) {
                    $("#ad").html("");
                    search();
                }
            });
        });



    });


    function search() {
        $.ajax({
            url:"searchAdmin",
            type:"POST",
            dataType:"json",
            success:function (data) {
                var da=eval("("+data+")");
                var str="";
                $(da).each(function (i,a) {
                    str+="<tr>"+
                        "<td>"+a.name+"</td>"+
                        "<td>"+a.pass+"</td>"+
                        "<td><a href='up?id="+a.id+"'>删除</a></td>"+
                        "</tr>";
                });
                $("#ad").append(str);
            }
        });
    }
</script>
</html>